package com.yijumao.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yijumao.dao.UserDao;
import com.yijumao.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author konley
 * @date 2020-10-26 20:58
 */

@Service
@Transactional
public class UserServiceImpl implements UserService{

    @Autowired
    private UserDao userDao;

    @Override
    public User login(User user) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<User>()
                .eq("username",user.getUsername())
                .eq("password",user.getPassword());
        List<User> users = userDao.selectList(queryWrapper);
        if(users.isEmpty()){
            return null;
        }else{
            return users.get(0);
        }
    }
}
